//
//  HomeTwoTableViewCell.m
//  好奇
//
//  Created by ***鹏辉 on 16/9/24.
//  Copyright © 2016年 Zuopenghui. All rights reserved.
//

#import "HomeTwoTableViewCell.h"
#import "UIImageView+WebCache.h"
@interface HomeTwoTableViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *icon;
@property (weak, nonatomic) IBOutlet UILabel *nameLable;
@property (weak, nonatomic) IBOutlet UILabel *subName;
@property (weak, nonatomic) IBOutlet UILabel *laiYuan;
@property (weak, nonatomic) IBOutlet UILabel *timeLable;
@property (weak, nonatomic) IBOutlet UIButton *zanBtn;
@property (weak, nonatomic) IBOutlet UIButton *pingLunBtn;

@end
@implementation HomeTwoTableViewCell
-(NSString *)Time:(HomeTableViewModel *)model{
    
    NSString*str = [NSString stringWithFormat:@"%@",model.post[@"publish_time"]];
    NSTimeInterval time = [str doubleValue] + 28800;
    NSDate * detaildate = [NSDate dateWithTimeIntervalSince1970:time];
    
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc]init];
    
    [dateFormatter setDateFormat:@"MM/dd HH:mm"];
    NSString * currentDateStr = [dateFormatter stringFromDate:detaildate];
    return currentDateStr;
}

-(void)setModel:(HomeTableViewModel *)model
{
   [self.icon sd_setImageWithURL:[NSURL URLWithString:model.image]];
   self.nameLable.text = model.post[@"title"];
   self.subName.text = model.post[@"description"];
   self.laiYuan.text = model.post[@"category"][@"title"];
   self.timeLable.text = [self Time:model];
   [self.pingLunBtn setTitle:[NSString stringWithFormat:@"%@",model.post[@"comment_count"]] forState:UIControlStateNormal];
   [self.zanBtn setTitle:[NSString stringWithFormat:@"%@",model.post[@"praise_count"]] forState:UIControlStateNormal];
}

//NSString*str=@"1368082020";//时间戳
//
//NSTimeIntervaltime=[strdoubleValue]+28800;//因为时差问题要加8小时 == 28800 sec
//
//NSDate*detaildate=[NSDatedateWithTimeIntervalSince1970:time];
//
//文／Kloar（简书作者）
//原文链接：http://www.jianshu.com/p/c3d040fc22e8
//著作权归作者所有，转载请联系作者获得授权，并标注“简书作者”。
//贾少宇  19:03:36
//NSDateFormatter*dateFormatter = [[NSDateFormatteralloc]init];
//
////设定时间格式,这里可以设置成自己需要的格式
//
//[dateFormattersetDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//
//NSString*currentDateStr = [dateFormatterstringFromDate:detaildate];
//
//
//
@end
